﻿using System;
using System.IO;

namespace WindowsGame1.Operations
{
    public class FileManager
    {
        public static void Load()
        {
            //try
            //{
            //    StreamReader buffer = new StreamReader("lab.txt");
            //    String line = buffer.re;
            //    Console.WriteLine("File Loaded!" +line);
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine("Savegame not found!" + e.Message +"\n"+ e.StackTrace);
            //}
        }

        public static String ReadCharacter(StreamReader reader)
        {
            return reader.Read().ToString();
        }

        public static String ReadCharacter(StreamReader reader, int amount)
        {
            String outMan = "";

            for (var i = 0; i < amount; i++)
            {
                var c = (char) reader.Read();

                if (c != -1)
                    outMan += c.ToString();
                else
                    break;
            }
            return outMan;
        }

        public static String ReadCharacterTillWhiteSpaces(StreamReader reader)
        {
            String outMan = "";
            var c = (char)reader.Read();
            while (c != 10 && c != -1)
                outMan += c.ToString();

            return outMan;
        }

        public static String ReadLine(StreamReader reader)
        {
            return reader.ReadLine();
        }

        //public static void Save()
        //{
        //    try
        //    {
        //        using (StreamWriter buffer = new StreamWriter("save.dat"))
        //        {
        //            buffer.Write( ActionsHandler.unlockedLevels );
        //            buffer.Write("\n");
        //            buffer.Write( SoundController.isSoundMuted() );
        //            buffer.Write("\n");
        //            buffer.Write( ActionsHandler.Game.graphics.IsFullScreen );
        //            buffer.Write("\n");
        //            buffer.Write(ActionsHandler.showTips);

        //            Console.WriteLine("File Saved!");
        //        }
        //    }
        //    catch (Exception e)
        //    {
        //        Console.WriteLine("Error while saving the game");
        //    }
        //}
    }
}
